package com.dbgs.insurance.insuredperson.activity.register;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.AppCompatButton;
import android.support.v7.widget.AppCompatImageView;
import android.support.v7.widget.AppCompatTextView;
import android.view.View;

import com.blankj.utilcode.util.ToastUtils;
import com.dbgs.insurance.insuredperson.R;
import com.dbgs.insurance.insuredperson.constants.ConstInt;
import com.hss.base.BaseActivty;
import com.xw.repo.XEditText;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2018/5/14.
 */

public class RegisterActivity extends BaseActivty {


    @BindView(R.id.close)
    AppCompatTextView close;
    @BindView(R.id.title)
    AppCompatTextView title;
    @BindView(R.id.xet_name)
    XEditText xetName;
    @BindView(R.id.btn_login)
    AppCompatButton btnLogin;
    @BindView(R.id.register)
    AppCompatTextView register;
    @BindView(R.id.return_img)
    AppCompatImageView returnImg;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        ButterKnife.bind(this);
        initData();
        initView();
        initListener();
    }

    @Override
    public void initData() {
        super.initData();
    }

    @Override
    public void initView() {
        super.initView();
        title.setText(getResources().getText(R.string.str_register_newuser));
        register.setVisibility(View.GONE);
        close.setVisibility(View.GONE);
        returnImg.setVisibility(View.VISIBLE);
    }

    @Override
    public void initListener() {
        super.initListener();

    }

    @OnClick({R.id.close, R.id.btn_login, R.id.return_img})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.return_img:
                finishActivity();
                break;
            case R.id.btn_login:
                if (xetName.getTrimmedString().length()!=11){
                    ToastUtils.showShort(R.string.str_input_right_phoneNo);
                }
                Intent intent = new Intent(RegisterActivity.this,
                        InputVerifyCodeActivity.class);
                intent.putExtra(InputVerifyCodeActivity.FLAG, 2);
                startActivityForResult(intent,ConstInt.REQUEST_REGISTER_CODE);
                break;
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode== ConstInt.REQUEST_REGISTER_CODE && resultCode == ConstInt.RESULT_VALUE_CHANGED){
            exit();
        }
    }
}
